/**
 * View allows you to build html for output
 */
Flair.View = function () {
	this.data = {};
	this.output = new Array();
	this.doRender = true;
	
	this.doNotRender = function (render) {
		if(render != undefined && render == true)
			this.doRender = true;
		else
			this.doRender = false;
	}
	
	/**
	 * Read a file for string contents
	 * @param {string} filename
	 * @return {string} file contents
	 */
	this.readFile = function (filename) {
		//var file = air.File.applicationStorageDirectory.resolvePath(filename); 
		var file = air.File.applicationDirectory.resolvePath(filename);
		var fstream = new air.FileStream();
		Flair.log('file path', file);
		fstream.open(file, air.FileMode.READ);
		var bytes = new air.ByteArray();
		fstream.readBytes(bytes, fstream.position, fstream.bytesAvailable);
		return bytes.toString();
	}
	
	/**
	 * append file contents to output string
	 * @param {file} filename
	 */
	this.appendFile = function (file) {	this.output.push( this.readFile(file) ); }
	/**
	 * append string contents to output string
	 * @param {string} contents
	 */
	this.appendString = function (string) { this.output.push(string); }
	/**
	 * prepend file contents to output string
	 * @param {file} filename
	 */
	this.prependFile = function (file) { this.output.unshift( this.readFile(file) ); }
	/**
	 * prepend string contents to output string
	 * @param {string} contents
	 */
	this.prependString = function (string) { this.output.unshift(string); }
	/**
	 * Set(overwrite) output string to file contents
	 * @param {file} filename
	 */
	this.setFile = function (file) { this.output = new Array( this.readFile(file) ); }
	/**
	 * Set(overwrite) output string to string contents
	 * @param {string} contents
	 */
	this.setString = function (string) { this.output = new Array(string); }
	
	/**
	 * Set window.data property value named pair
	 * @param {name} property name
	 * @param {value} property value
	 */
	this.setData = function (name, value) { this.data[name] = value; }
	
	/**
	 * Return the JSON data object that will be passed to local scope
	 * @return {JSON} data
	 */
	this.getData = function() { return this.data; }
	
	/**
	 * Return the html output string that will be passed to the render container
	 * @return {string} html output
	 */
	this.getOutput = function () { return this.output.join(); }
};